package com.bjbn.controller;

import com.bjbn.dto.*;
import com.bjbn.service.Webapi4LbsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.Map;

/**
 * 综合定位平台API控制器
 *
 * @author bjbn
 */
@RestController
@RequestMapping("/CAN/LBS/IntegratedPositioningSystem/V1")
@Tag(name = "高精度综合定位系统接口API", description = "高精度综合定位系统接口相关接口")
public class LbsController {
    @Autowired
    private Webapi4LbsService webapiService;

    /**
     * LBS-获取定位标签列表-V1
     *
     * @param request 查询请求
     * @return 响应结果
     */
    @PostMapping("/api/tags/pages")
    @Operation(summary = "获取定位标签列表", description = "获取定位标签列表")
    public Mono<ResponseEntity<Map<String, Object>>> lbsTagsPagesList(@RequestBody LbsTagsRequest request) {
        return webapiService.lbsTagsPagesList(request)
                .map(ResponseEntity::ok)
                .defaultIfEmpty(ResponseEntity.noContent().build());
    }

    /**
     * LBS-获取告警列表-V1
     *
     * @param request 查询请求
     * @return 响应结果
     */
    @PostMapping("/api/alarms/pages")
    @Operation(summary = "LBS-获取告警列表-V1", description = "LBS-获取告警列表-V1")
    public Mono<ResponseEntity<Map<String, Object>>> lbsAlarmsPagesList(@RequestBody LbsAlarmsRequest request) {
        return webapiService.lbsAlarmsPagesList(request)
                .map(ResponseEntity::ok)
                .defaultIfEmpty(ResponseEntity.noContent().build());
    }

    /**
     * LBS-获取位置信息-V1
     *
     * @param request 查询请求
     * @return 响应结果
     */
    @PostMapping("/XIY/LBS/getPositions")
    @Operation(summary = "LBS-获取位置信息-V1", description = "LBS-获取位置信息-V1")
    public Mono<ResponseEntity<Map<String, Object>>> lbsPositionPagesList(@RequestBody LbsPositionRequest request) {
        return webapiService.lbsPositionPagesList(request)
                .map(ResponseEntity::ok)
                .defaultIfEmpty(ResponseEntity.noContent().build());
    }


    /**
     * LBS-获取定位对象列表-V1
     *
     * @param request 查询请求
     * @return 响应结果
     */
    @PostMapping("/api/trackables/pages")
    @Operation(summary = "LBS-获取定位对象列表-V1", description = "LBS-获取定位对象列表-V1")
    public Mono<ResponseEntity<Map<String, Object>>> lbsTrackablesPagesList(@RequestBody LbsStrackableRequest request) {
        return webapiService.lbsTrackablesPagesList(request)
                .map(ResponseEntity::ok)
                .defaultIfEmpty(ResponseEntity.noContent().build());
    }
}
